/** COPYRIGHT(C) 2008. Loc Phan. All Rights Reserved.
    A class that store info of a hourly worker
    @author Loc Phan
    @version 1.01 2008-12-1
*/

package edu.sjsu.phan.postlab14;

public class HourlyWorker extends Worker
{
   final int MAXHOUR = 40;
   final double OVERTIMERATIO = 1.5;
   
   /**Constructs a hourly worker
    * 
    * @param name Worker's name
    * @param salaryRate Worker's salary
    */
   public HourlyWorker(String name, double salaryRate)
   {
      super(name, salaryRate);

   }
   /**Returns value of weekly paycheck
    * 
    * @param hour Number of hours worked
    * @return Money (in dollar)
    */
   public double computePay(int hour)
   {
      double result = 0;
      if(hour>MAXHOUR)
      {
         result = (hour-MAXHOUR)*(OVERTIMERATIO*super.getSalaryRate())+MAXHOUR*super.getSalaryRate();
      }
      else if(hour>0&&hour<MAXHOUR)
      {
         result = hour*super.getSalaryRate();
      }
      return result;
   }
}
